def cell_division_3(n):
    if n==1 or n==2 or n==3:
        return 1
    if n>=4:
        t1,t2,t3=1,1,1
        index=4
        while index<n+1:
            t4=t1+t3
            t1=t2
            t2=t3
            t3=t4
            index+=1
        return t4





if __name__=="__main__":
    while True:
        n=int(input().strip())
        if n==0:
            break
        print(cell_division_3(n))